package com.example.pdfsearch.adapter;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.pdfsearch.R;
import com.example.pdfsearch.bean.PDFFileInfo;
import com.example.pdfsearch.util.PDFUtil;

import java.util.List;

/**
 * @作者: njb
 * @时间: 2019/9/11 20:31
 * @描述: pdf文件适配器类
 */
public class PDFAdapter extends BaseQuickAdapter<PDFFileInfo, BaseViewHolder> {

    public PDFAdapter(@Nullable List<PDFFileInfo> data) {
        super(R.layout.item_pdf,data);
    }

    @Override
    protected void convert(BaseViewHolder helper, PDFFileInfo item) {
        if(item == null){
            return;
        }
        helper.setText(R.id.tv_name , item.getFileName());
        helper.setText(R.id.tv_size , PDFUtil.FormetFileSize(item.getFileSize()));
        helper.setText(R.id.tv_time , item.getTime());
        if (item.isSelect()){
            helper.getView(R.id.img_select).setBackgroundResource(R.mipmap.reward_selection_ok);
        }else {
            helper.getView(R.id.img_select).setBackgroundResource(R.mipmap.reward_selection_no);
        }
    }
}
